package com.yuqiao.read.jvm;

/**
 * 多线程导致内存溢出
 * 不要轻易运行 会导致系统假死
 * -Xss2M
 */
public class JavaVMStackOom {
    private void dontStop(){
        while (true){

        }
    }

    public void stackLeakByThread(){
        while (true){
            Thread thread = new Thread(new Runnable() {
                @Override
                public void run() {
                    dontStop();
                }
            });
            thread.start();
        }
    }

    public static void main(String[] args) {
        JavaVMStackOom javaVMStackOom = new JavaVMStackOom();
        javaVMStackOom.stackLeakByThread();
    }
}
